﻿using Network.UpdateData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace SFJDManagement.SocketHandle
{
    /// <summary>
    /// Servers to Client 消息处理程序
    /// </summary>
    class SCLanHandle
    {
        public SCLanHandle(Socket socket, byte[] bytes)
        {
            try
            {
                Packet packet = new Packet(bytes);
                Debug(packet);
                if (packet.GuidTarget != Guid.Empty && packet.GuidTarget != Runtime.config.UserGuid)
                {
                    return;
                }
                object[] parameters = new object[1];
                parameters[0] = packet;
                Type type = Runtime.dictionary[packet.Code];
                Activator.CreateInstance(type, socket, packet);
            }
            catch { }
        }

        private void Debug(Packet packet)
        {
            Console.WriteLine("返回消息： " + packet.ToString());
        }
    }
}
